package com.sky.mapper;

import com.sky.dto.ShoppingCartDTO;
import com.sky.entity.ShoppingCart;
import org.apache.ibatis.annotations.*;

import java.util.List;

/**
 * @version 1.0
 * @Author 郭腾高
 * @Date 2024/9/25 20:39
 */
@Mapper
public interface ShoppingCartMapper {
    /*查询用户对应购物车是否有菜品或套餐*/
    ShoppingCart select(ShoppingCart shoppingCart);
   /*购物车中添加相关菜品或套餐*/
    @Insert("insert into shopping_cart(name,user_id,dish_id,setmeal_id,dish_flavor,amount,image,create_time)" +
            " values(#{name},#{userId},#{dishId},#{setmealId},#{dishFlavor},#{amount},#{image},#{createTime})")
    void add(ShoppingCart shoppingCart1);
    /*购物车菜品或套餐数量更新*/

    void update(ShoppingCart shoppingCart1);
    /*查询购物车*/
    List<ShoppingCart> list(ShoppingCart build);


    /*清空购物车*/
    @Delete("delete from shopping_cart where user_id = #{userId}")
    void deleteAll(ShoppingCart build);
    /*删除单个购物车商品*/
    void deleteOne(ShoppingCart shoppingCart);
    /*批量插入购物车*/
    void insertBatch(List<ShoppingCart> shoppingCartList);
}
